{extend name="public/base" /} {block name="body"}
<div class="content-tabs">
	<ol class="breadcrumb">
		<li>
			<a href="{:url('index/index')}"><i class="fa fa-home"></i></a>
		</li>
		<li><strong>商家列表</strong></li>
	</ol>
</div>
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<form id="myForm" class="form-horizontal m-t" method="post" action="{:url('index')}">
          	<div class="form-group">
      			商户性质 <select class="bank" name="store_property">
                <option value="0">商家类型</option>
                <option value="1">个人</option>
                <option value="2">商家</option>
                <option value="3">工厂</option>
            	</select>
        		商户类型 <select class="bank" name="agent_type">
 				<option value="0">商户类型</option>
                <option value="1">普通商家</option>
                <option value="2">加盟商</option>
            	</select>
         		行业类型 <select name="license" class="bank">
				<option value="0">行业分类</option>
				{foreach name="tralist" item="vo"}
				<option value="{$vo.id}">
					{$vo.title}
				</option>
				{/foreach}
				</select>
				是否有证件 <select class="bank" name="is_credentials">
 				<option value="0">请选择</option>
                <option value="1">有</option>
                <option value="2">无</option>
           	 	</select>
    			保证金 <select class="bank" name="is_foregift">
 				<option value="2">请选择</option>
                <option value="1">已缴纳</option>
                <option value="0">未缴纳</option>
            	</select><br/>
   				是否分销 <select class="bank" name="is_distribution">
 				<option value="2">请选择</option>
                <option value="1">开启</option>
                <option value="0">关闭</option>
            	</select>
      			附近显示 <select class="bank" name="is_display">
 				<option value="2">请选择</option>
                <option value="1">开启</option>
                <option value="0">关闭</option>
            	</select>
       			审核状态 <select class="bank" name="status">
 				<option value="0">请选择</option>
                <option value="1">正常</option>
                <option value="2">未审核</option>
            	</select>
    			&nbsp;&nbsp;&nbsp;创建时间
    			<input id='start_time' name='start_time'  style="width: 170px;" onclick='WdatePicker()' type='text' placeholder="开始时间" class="bank" />
				至<input id='end_time' name='end_time'  style="width: 170px;" onclick='WdatePicker()' type='text' placeholder="结束时间" class="bank" />	
				<br/>商户名称 <input type="text" name='store_name' placeholder="请输入商家名称" class="bank"> 
				<span class="bank"><button type="submit" class="btn btn-sm btn-primary"> <li class="fa fa-search"> 搜索</li></button> </span>
            </div>
           
	       	
        </form>
		<div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                            	<th>用户id</th>
                                <th>商户名</th>
                                <th>商户类型</th>
                                <th>行业</th>
                                <th>商品数量</th>
                                <th>证件</th>
                                <th>保证金</th>
                                <th>是否分销</th>
                                <th>是否附近显示</th>
                                <th>余额</th>
								<th>积分</th>
                                <th>联系电话</th>
                                <th>审核状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="list">
                        	{volist name="list" id='ad'}
                        	<tr>
								<td>{$ad.u_id}</td>
                        		<td><a href="{:url('agentinfo',['id'=>$ad.id])}" >{$ad.store_name}</a></td>
                        		<td>
                        			{if $ad.agent_type == 1}
                        			普通商家
                        			<br />
                        		<a href="{:url('examine',['id'=>$ad.id])}" class="btn btn-primary bnt-sm ajax-do">
								升级</a>
                        			{else}
                        			加盟商	
                        			{/if}
                        		</td>
                        		<td>{$ad.title}</td>
                        		<td>
                        			{if $ad.count > 0} 
                        			 {$ad.count}
                        			{else}
                        			0
                        			{/if}
                        		</td>
                        		<td class="text-center">
                        			{if $ad.is_credentials == 1}
                        			是
                        			{else}
                        			否	
                        			{/if}
                        		</td>
                        		<td class="text-center">
                        			{$ad.foregift_money}</br>
                        			{if $ad.is_foregift == 1}
                        			是
                        			{else}
                        			否	
                        			{/if}
                        		</td>
                        		<td> 
	                        		<div class="onoffswitch">
	                                <input type="checkbox" data-id="{$ad.id}" onclick="update_dis(this)" value="{$ad.is_distribution}" id="is_distribution{$ad.id}" name="is_distribution{$ad.id}" {if $ad.is_distribution}checked{/if} class="onoffswitch-checkbox" >
	                                <label class="onoffswitch-label" for="is_distribution{$ad.id}">
	                                    <span class="onoffswitch-inner"></span>
	                                    <span class="onoffswitch-switch"></span>
	                                </label>
	                        		</div>
                        		</td>
                        		<td>
                            		<div class="onoffswitch">
	                                <input type="checkbox" onclick="update_xs(this)" class="onoffswitch-checkbox" value="{$ad.is_display}" data-id="{$ad.id}" id="is_display{$ad.id}"  name="is_display{$ad.id}" {if $ad.is_display}checked{/if} >
                                	<label class="onoffswitch-label" for="is_display{$ad.id}">
	                                    <span class="onoffswitch-inner"></span>
	                                    <span class="onoffswitch-switch"></span>
                            		</label>
                            		</div>
                        		</td>
                        		<td>{$ad.store_balance}<br />
                        		<input type="button" value="充值" id="credit2"class="btn btn-primary bnt-sm" onclick="balance({$ad.id})">
                        		</td>
                        		<td>{$ad.score}<br />
                        		<input type="button" value="充值" id="credit1"class="btn btn-primary bnt-sm" onclick="integral({$ad.id})">
                        		</td>
                        		<td>{$ad.store_tel}</td>
                        		<td class="text-center">
                        			{if $ad.status == 1}
                        			 审核通过
                        			{elseif $ad.status == 2}
                        			<a href="{:url('toexamine',['id'=>$ad.id])}" class="btn btn-danger bnt-sm ajax-do">
										<i class="fa fa-paste"></i> 未审核</a>
                        			{/if}
                        		</td>
                        		<td>                 			
									{if $ad.store_state == 2}
									<a href="{:url('frozen',['id'=>$ad.id, 'status'=>$ad.store_state])}" class="btn btn-primary bnt-sm ajax-do">
									<i class="fa fa-unlock"></i> 激活</a>
                        			{elseif $ad.store_state == 1}
                        			<a href="{:url('frozen',['id'=>$ad.id, 'status'=>$ad.store_state])}" class="btn btn-danger bnt-sm ajax-do">
									<i class="fa fa-lock"></i> 冻结</a>                  			
                        			{/if}
									<a href="{:url('chainlist',['id'=>$ad.id])}" class="btn btn-primary bnt-sm">
									<i class="fa fa-paste"></i> 连锁店</a>
                        		</td>
                        	</tr>
                        	{/volist}
                        </tbody>
                    </table>
                    <div style="text-align: right;">
                      {$list->render()}
                    </div>
                </div>
            </div>
            </div>
</div>
{/block} {block name="script"}
<script src="__JS__/jquery.form.js"></script>
<script src="__LIB__/datepicker/WdatePicker.js"></script>
<script>
	function update_dis(obj){
		var value = $(obj).val();
		var chk=$(obj).is(':checked');
			$.ajax({
				type:"post",
				data:{id:$(obj).data("id"),is_distribution:value==1?0:1},
				url:"update_agent",
				success:function(data){
					layer.msg(data.msg);
					if(data.code==200){
						$(obj).val(value==1?0:1);
					}
				}
			});
	}
	function update_xs(obj){
		var value = $(obj).val();
		var chk=$(obj).is(':checked');
			$.ajax({
				type:"post",
				data:{id:$(obj).data("id"),is_display:value==1?0:1},
				url:"update_agent",
				success:function(data){
					layer.msg(data.msg);
					if(data.code==200){
						$(obj).val(value==1?0:1);
					}
				}
			});
	}
	function balance(id){
		var tel=parent.layer.prompt({title: '输入充值金额',formType: 0}, 
	    function(integral){layer.open({content: '确认充值金额为'+integral+'？',
					btn: ['确认', '取消'],yes: function(index, layero) {window.location.href='credit/id/'+id+'/integral/'+integral;},
													btn2: function(index,layero) {},
						                        cancel: function() {
						                            //右上角关闭回调  
					}
				});
		});
	}
	function integral(id){
		var tel=parent.layer.prompt({title: '输入充值积分',formType: 0}, 
	    function(integral){layer.open({content: '确认充值积分为'+integral+'？',
					btn: ['确认', '取消'],yes: function(index, layero) {window.location.href='integral/id/'+id+'/integral/'+integral;},
													btn2: function(index,layero) {},
						                        cancel: function() {
						                            //右上角关闭回调  
						                      }
				});
		});
	}
</script>
<style>
.bank{
	width: 150px;
    height:30px;
    border-radius:5px;
}
</style>
{/block}